﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
using Oracle.DataAccess.Client;
//using System.Data.OracleClient;
namespace _3TierDemo.DAL
{
    class CommonDAO
    {
        private string strConnect;
        public string StrConnect
        {
            get { return strConnect; }
            set { strConnect = value; }
        }
        public CommonDAO()
        {
           
            //StrConnect = "DATA SOURCE=ORCL;USER ID=SYSTEM;Password=Oracle123;Integrated Security=no;";
            StrConnect = "Data Source=orcl;User Id=TESTSV;Password=123456;";
        }
        protected bool execNonQuery(string strQuery)
        {           
            bool check = true;
            try
            {
                //OleDbConnection con = new OleDbConnection(StrConnect);
                //con.Open();

                OracleConnection con = new OracleConnection(strConnect);
                con.Open();
                //OleDbCommand com = new OleDbCommand(strQuery, con);
                OracleCommand com = new OracleCommand(strQuery, con);
                //com.CommandType = CommandType.Text;
                com.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception ex)
            {
                check = false;
            }
            return check;
        }

        protected DataTable execSelect(string strSelect)
        {
            OracleConnection con = new OracleConnection(strConnect);
            con.Open();
            OracleDataAdapter da = new OracleDataAdapter(strSelect, con);
            DataTable dt = new DataTable();
            da.Fill(dt);
            con.Close();
            return dt;
        }
    }
}
